Skip to content

Introduce the gene_constraint parameter #326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Jul 6, 2025
Merged

Introduce the gene_constraint parameter #326

merged 26 commits into from
Jul 6, 2025

Conversation

ahmedfgad
Copy link
Owner

There are many improvements but the main contribution is introducing a new parameter called gene_constraint that accepts constraints about each individual gene.

For example,

pygad.GA(..., gene_constraint=[lambda solution: solution[0]>20])

It has the limitation of not detecting the dependencies among the genes. For example, it must detect that gene 0 depends on gene 1 and thus it has to enforce the gene constraint for gene 1 at first. But this is not supported yet.

pygad.GA(..., gene_constraint=[lambda solution: solution[0]>solution[1], lambda solution: solution[0]>20])

@ahmedfgad ahmedfgad merged commit e6ba8e1 into master Jul 6, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant